package com.lmf.mock.starter.autoconfigure;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * Mock服务自动配置类
 */
@Configuration
@ConditionalOnClass(name = "javax.sql.DataSource")
@ConditionalOnProperty(prefix = "mock", name = "enabled", havingValue = "true", matchIfMissing = true)
@EnableConfigurationProperties(MockProperties.class)
@ComponentScan("com.lmf.mock.starter.autoconfigure")
@MapperScan("com.lmf.mock.starter.autoconfigure.mapper")
@Slf4j
public class MockAutoConfiguration {

    private final MockProperties mockProperties;

    public MockAutoConfiguration(MockProperties mockProperties) {
        this.mockProperties = mockProperties;
        log.info("[mock-starter] MockAutoConfiguration initialized. enabled={}, basePath={}, adminEnabled={}, adminPath={}",
                mockProperties.isEnabled(),
                mockProperties.getBasePath(),
                mockProperties.isAdminEnabled(),
                mockProperties.getAdminPath());
    }
}